function createFolderDiv() {	
    var div = document.createElement("div");
    div.id = "createFolder";
    div.innerHTML = "<h3> &nbsp&nbspFolder Position</h3><hr/>";
    var div2 = document.createElement("div");
    div2.style.height = "310";
    div2.style.overflow = "auto";
    
    div2.innerHTML = '<form>' + 
                     '&nbsp&nbspPosition: &nbsp&nbsp<input type="text" id="folderPath" /><br />' +
                     '</form>';
    
    for (var j = 10; j > 0; j--)
		div2.innerHTML = div2.innerHTML + "&nbsp";
    var moreButton = document.createElement('input');
    moreButton.type = 'button';
    moreButton.value = "    create    ";
    moreButton.name = "Create";
    moreButton.setAttribute("onclick", "create()");
    div2.appendChild(moreButton);
    var cancelButton = document.createElement('input');
    cancelButton.type = 'button';
    cancelButton.value = "   cancel   ";
    cancelButton.name = "cancelbutton";
    cancelButton.setAttribute("onclick", "cancelCreate()");
    div2.appendChild(cancelButton);
    
	div.appendChild(div2);
    div.appendChild(document.createElement('br'));
    div.appendChild(document.createElement('br'));
    div.appendChild(document.createElement('br'));
    div.appendChild(document.createElement('br'));
    document.body.appendChild(div);
}


function create() {
    var contPath = document.getElementById("folderPath").value;
    //alert(contPath);
    // check path
    if(contPath=="" || !PathValidation(contPath))
    {
        alert("please enter valid path");
    } 
    else
    {
		$.post('savefile.php',
		{
			'dir':contPath,
		}
		);
		fileTreeRefresh();
		cancelCreate();
    }
}

function cancelCreate() {
	var div = document.getElementById("createFolder");
	document.body.removeChild(div);
}

function PathValidation(contPathLinux)
{
    for(var k=0;k<contPathLinux.length;k++){
        if(contPathLinux.charAt(k).match(/^[\\]$/) ){
            return false;
        }
    }
    if(contPathLinux.charAt(0) != "/")
    {
        return false;
    }
    if(contPathLinux.charAt(0) == "/" && contPathLinux.charAt(1) == "/")
    {
        return false;
    }
    return true;
}
